<?php

// ROOT_PATH check
	if(!defined('ROOT_PATH')) define('ROOT_PATH', str_replace('kernel', '', dirname(__FILE__)));

// required files
	require_once ROOT_PATH.'/kernel/lib/defines/system.php';
	require_once ROOT_PATH.'/config.php';

// main class file
	include ROOT_PATH.'/kernel/lib/class/cosa.php';
	$cosa = new Cosa();

// database class file
	include ROOT_PATH.'/kernel/lib/class/db.php';
	$db = new db();
	$cosa->init();

// user class file
	include ROOT_PATH.'/kernel/lib/class/user.php';
	$user = new User();
	if(isset($_GET['exit'])) $logoutAttempt = $user->logout();
	if(isset($_POST['uname'], $_POST['pass'], $_POST['login']) && $cosa->system('installed')) $loginAttempt = $user->login($_POST['uname'], $_POST['pass']);

// plugins
	include ROOT_PATH.'/kernel/lib/class/plugins.php';
	$plugins = new Plugins();

// language class file
	include ROOT_PATH.'/kernel/lib/class/lang.php';
	$lang = new Lang();
	$bool = array($lang->get('no'), $lang->get('yes'));
	$boolImg = array($cosa->system('base-url').'/kernel/files/img/icons/s/close.gif', $cosa->system('base-url').'/kernel/files/img/icons/s/check.gif');

// if user is logged in
	if($user->isLoggedIn()) {
		
		// required module vars
			$m = (isset($_REQUEST['m'])) ? $_REQUEST['m'] : DEFAULT_MODULE;		# module
			$s = (isset($_REQUEST['s'])) ? $_REQUEST['s'] : false;				# sub module
		
		// sorting, actions, etc...
			$sort = (isset($_REQUEST['sort'])) ? $_REQUEST['sort'] : 'id';		# table sorting
			$dir = (isset($_REQUEST['dir'])) ? $_REQUEST['dir'] : 'ASC';		# table sorting direction
			$add = (isset($_REQUEST['add'])) ? true : false;					# item to add
			$edit = (isset($_REQUEST['edit'])) ? $_REQUEST['edit'] : false;		# item to edit
			$del = (isset($_REQUEST['del'])) ? $_REQUEST['del'] : false;		# item to delete
		
		// set action
			$a = 'overview';
			if($add || $edit) $a = 'frm';
			if($del) $a = 'del';
		
		// include module files
			include ROOT_PATH.'/kernel/lib/class/module.php';
			include ROOT_PATH.'/kernel/lib/class/modules.php';
			$modules = new Modules();
		
		// path class
			include ROOT_PATH.'/kernel/lib/class/path.php';
			$path = new Path();
		
		// file class
			include ROOT_PATH.'/kernel/lib/class/file.php';
			$file = new FileHandler();
		
	} else {
		
		$m = false;
		
	}

?>